package com.platform.modules.job.task;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.platform.common.utils.Constant;
import com.platform.modules.mall.entity.MallWhitelistEntity;
import com.platform.modules.mall.service.MallWhitelistService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Slf4j
@Component("whiteListTask")
public class WhiteListTask {
    @Autowired
    MallWhitelistService whitelistService;

    @Transactional(rollbackFor = Exception.class)
    public void lapseWhitelist(){
        //使白名单失效
        whitelistService.lambdaUpdate().set(MallWhitelistEntity::getValid, Constant.ZERO).lt(MallWhitelistEntity::getLapseTime,new Date()).update();
    }

}
